package cn.his.medical.phismange.adapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import cn.his.medical.phismange.R
import cn.his.medical.phismange.view.CustomView

/**
 * 作者：xiewei on 2018/4/17 17:10
 * 邮箱：xiewei19910115@163.com
 */
class CusAdapter<M>(val mList: ArrayList<M>?, val context: Context) : CustomView.T {
    override fun getCount(): Int {
        if (mList != null) {
            return mList.size
        } else {
            return 0
        }
    }

    fun getList(): ArrayList<M>? = mList;

    override fun getItem(position: Int): M? {
        if (mList != null) {
            return mList.get(position)
        }else return null
    }

    override fun getView(position: Int, view: View?, viewGroup: ViewGroup?): View {
        var cusHolder : CusViewHolder
        var v : View
        if (view == null){
            v = View.inflate(context,R.layout.exam_activity,null)
            cusHolder = CusViewHolder(v)
        }else{
            v = view
            cusHolder = v.tag as CusViewHolder
            cusHolder.Llayout.removeAllViews()
        }

        var m = mList?.get(position) as M
        for (i in 0..mList.size){

        }

        return v
    }

    class CusViewHolder(val viewItem : View){
        var textView = viewItem.findViewById<TextView>(R.id.exam_view)
        var Llayout = viewItem.findViewById<LinearLayout>( R.id.up_roll)
    }

}